package com.fwtai.web;

import com.fwtai.bean.PageFormData;
import com.fwtai.datasource.DaoHandle;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;

/**
 * 积分兑换记录访问数据库
 * @作者 田应平
 * @版本 v1.0
 * @创建时间 2023-04-19 10:20:18
 * @QQ号码 444141300
 * @Email service@yinlz.com
 * @官网 <url>http://www.fwtai.com</url>
*/
@Repository
public class ConversionDao{

  private final DaoHandle dao;

  public ConversionDao(final DaoHandle dao){
    this.dao = dao;
  }

  public int editBatchAudit(final PageFormData formData){
    return dao.execute("user_securities_record.updateUserSecuritiesRecord",formData);
  }

  @Transactional
  public int editBatchAudit(final PageFormData formData,final HashMap<String,Object> account_out){
    final int rows = dao.execute("user_securities_record.updateUserSecuritiesRecord",formData);
    if(rows > 0){
      dao.execute("user_securities_record.updateUserIntegral",formData);
      dao.execute("user_securities_record.add_user_account_out",account_out);
    }
    return rows;
  }

  public List<HashMap<String,Object>> getListData(final PageFormData formData){
    return dao.queryForListHashMap("user_securities_record.listData",formData);
  }

  public Integer getListTotal(final PageFormData formData){
    return dao.queryForInteger("user_securities_record.listTotal",formData);
  }
}